//导入各个框架、组件、插件
import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
import appLogin from "@/views/appLogin.vue";
import appHome from "@/views/appHome.vue";
import appUser from "@/components/appUser.vue";
import appOrder from "@/components/appOrder.vue";
import appGoods from "@/components/appGoods.vue";
Vue.use(VueRouter);

const routes = [
  {
    path: "/", //根路由,开发时请更改组件为appLogin
    name: "Home",
    component: Home,
  },
  {
    path: "/about",
    name: "About",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/About.vue"),
  },
  {
    path: "/login", //登录模块
    name: "login",
    component: appLogin,
  },
  {
    path: "/home", //主页
    name: "home",
    redirect: "/home/user",
    componente: appHome,
    children: [
      //设置子路由
      {
        path: "user", //用户管理
        name: "user",
        component: appUser,
      },
      {
        path: "goods", //商品管理
        name: "goods",
        component: appGoods,
      },
      {
        path: "order", //订单管理
        name: "order",
        component: appOrder,
      },
    ],
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
